package com.zzy.furns.dao.impl;

import com.zzy.furns.dao.BasicDAO;
import com.zzy.furns.dao.OrderItemDAO;
import com.zzy.furns.domain.OrderItem;

import java.util.List;

public class OrderItemDAOImpl extends BasicDAO<OrderItem> implements OrderItemDAO {
    @Override
    public Integer saveOrderItem(OrderItem orderItem) {
        String sql = "INSERT INTO order_item(`name`,price,count,total_price,order_id) VALUES(?,?,?,?,?)";
        return update(sql,orderItem.getName(),orderItem.getPrice(),orderItem.getCount(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemListByOrderId(String orderId) {
        String sql = "SELECT id,`name`,price,count,total_price AS totalPrice,order_id AS orderId FROM order_item WHERE order_id = ?";
        return queryMulti(sql, OrderItem.class,orderId);
    }
}
